/*******************************************************************************
HH and JT graphs for 3IE report

 Date Created: 20200131, NAA
 Last Edited: 
 Edited by: 

*******************************************************************************/

*************************** HH survey graphs ***********************************

**interest in working, by gender
recode mem_activity_ (99=.)
recode mem_job_interest_ (99=.) (7=.)
gen interested_working = 0 if mem_job_interest_ >= 4 & mem_job_interest_ != . //people who are not currently working and are not interested in working
replace interested_working = 1 if mem_activity_ == 1 //people who are already working
replace interested_working = 2 if initial_interest == 1

lab def int_work 0 "Not Interested in Working" 1 "Already Working" 2 "Signed up for Job Talash"
lab val interested_working int_work

count if gender == 1 & interested_working != .
local num_m =`r(N)'
count if gender == 2 & interested_working != .
local num_f =`r(N)'

catplot interested_working gender, percent(gender) stack asyvars ///
					recast(bar) graphregion(color(white)) ///
					var1opts(label(ang(45) labsize(3))) ///
					title("Interest in Working") b1title("") l1title("") ///
					ytitle("% of respondents", size(small)) legend(cols(1)) $shades5 ///
					note("27% of respondents already working signed up for Job Talash" " " "{it: no. male respondents = `num_m', no. female respondents = `num_f' }" , size(vsmall)) 


**interest in JT, by education_level
lab def jt_int 1 "Yes" 0 "No"
lab val initial_interest jt_int

count if mem_ed_ == 1 
local num_1 =`r(N)'
count if mem_ed_ == 2 
local num_2 =`r(N)'
count if mem_ed_ == 3 
local num_3 =`r(N)'
count if mem_ed_ == 4 
local num_4 =`r(N)'
count if mem_ed_ == 5 
local num_5 =`r(N)'
count if mem_ed_ == 6 
local num_6 =`r(N)'
count if mem_ed_ == 7 
local num_7 =`r(N)'

catplot initial_interest mem_ed_, percent(initial_interest) asyvars ///
					recast(bar) graphregion(color(white)) ///
					title("Signed up for Job Talash") subtitle("by education level") ///
					b1title("") l1title("") ///
					var1opts(label(ang(0) labsize(small))) ///
					var2opts(label(ang(0) labsize(vsmall))) ///
					ytitle("% of respondents", size(small)) legend(cols(3)) ///
					note(" " "{it: Pri Incomp = `num_1', Pri = `num_2', Middle = `num_3', Matric = `num_4'} {it: Inter = `num_5', Bachelors = `num_6', Masters/PhD = `num_7'}", size(vsmall)) 


**interest in JT by education and gender
forval s = 1(1)2 {
	forval e = 1(1)7 {
		count if mem_gender_ == `s' & mem_ed_ == `e' & mem_jobservice_interest_ != . 
		local c_`s'_`e' = `r(N)'
	}	
}	

	bysort mem_ed_ mem_gender_: egen total_edu_sex = count(1) if  mem_jobservice_interest_ != . // counting total members for each ed. cat. and sex, which were asked about their interest in the service. 
	bysort mem_ed_ mem_gender mem_jobservice_interest_:  egen total_js_edu_sex = count(1)	if mem_jobservice_interest_ != . 		// counting by educ. and gender, those who are interested. 
		gen intrst_js_edu_sex_p = total_js_edu_sex*100/total_edu_sex if mem_jobservice_interest_ == 1
	graph bar (mean) intrst_js_edu_sex_p, /// 
		over(mem_gender_, label(angle(forty_five))) over(mem_ed_, label(angle(forty_five))) yscale(range(0 100)) ylabel(#5) ytitle("") ///
		$region1	///
		note("MALE: Pri. Incomplete = `c_1_1', Pri. Complete = `c_1_2', Middle Complete= `c_1_3'," "Matric Complete = `c_1_4', Inter. Complete = `c_1_5', Bachelor's Complete = `c_1_6'," "Post Grad. Complete = `c_1_7' " /// 
		"FEMALE: Pri. Incomplete = `c_2_1', Pri. Complete = `c_2_2', Middle Complete= `c_2_3'," "Matric Complete = `c_2_4', Inter. Complete = `c_2_5', Bachelor's Complete = `c_2_6'," "Post Grad. Complete = `c_2_7' ") ///
		title("Would you like to enroll for JT Service?"  "By Education and Gender")


**likelihood of taking a job tranport by education
count if mem_ed_ == 1 & mem_job_yes_transport_ != .
local num_1 =`r(N)'
count if mem_ed_ == 2 & mem_job_yes_transport_ != .
local num_2 =`r(N)'
count if mem_ed_ == 3 & mem_job_yes_transport_ != .
local num_3 =`r(N)'
count if mem_ed_ == 4 & mem_job_yes_transport_ != .
local num_4 =`r(N)'
count if mem_ed_ == 5 & mem_job_yes_transport_ != .
local num_5 =`r(N)'
count if mem_ed_ == 6 & mem_job_yes_transport_ != .
local num_6 =`r(N)'
count if mem_ed_ == 7 & mem_job_yes_transport_ != .
local num_7 =`r(N)'


catplot mem_job_yes_transport_ mem_ed_, percent(mem_ed_) stack asyvars ///
					recast(bar) graphregion(color(white)) ///
					title("Would you be more likely to take a job if transport is provided?", size(medium))  subtitle("(subscribers indicating initial openness to taking a job)", size(small)) ///
					b1title("") l1title("") $shades5 ///
					var2opts(label(ang(0) labsize(vsmall))) ///
					ytitle("% of respondents", size(vsmall)) legend(size(small))  ///
					note("{it: If safe transportation, i.e. a pick and drop service from the office, will be provided to you, would you be more likely to take the job?}" "{it: Pri Incomp = `num_1', Pri = `num_2', Middle = `num_3', Matric = `num_4'} {it: Inter = `num_5', Bachelors = `num_6', Masters/PhD = `num_7'}", size(vsmall)) 

*************************** JT baseline graphs ***********************************

keep if initial_interest==1

**Education level, by gender
clonevar edu = education_level
replace edu = round(edu, 1)
recode edu (42=40) (44=40) (46=40) (50=70) (60=70) (120=.) (130=.)

lab def edu 10 "None" 20 "Primary" 30 "Middle" 40 "Matric" 70 "Inter" 80 "Bachelors" 90 "Masters" 100 "PhD" 110 "Other"
lab val edu edu

set scheme s2gcolor

count if gender_resp == 1 
local num_f =`r(N)'
count if gender_resp == 2 
local num_m =`r(N)'
count if edu == 10
local num_10 = `r(N)'
count if edu == 20
local num_20 = `r(N)'
count if edu == 30
local num_30 = `r(N)'
count if edu == 40
local num_40 = `r(N)'
count if edu == 70
local num_70 = `r(N)'
count if edu == 80
local num_80 = `r(N)'
count if edu == 90
local num_90 = `r(N)'
count if edu == 100
local num_100 = `r(N)'
count if edu == 110
local num_110 = `r(N)'


catplot gender_resp edu, percent(gender_resp) asyvars ///
					recast(bar) graphregion(color(white)) ///
					var1opts(label(ang(45) labsize(3))) ///
					title("Highest Education Level") ///
					subtitle("Job Talash Subscribers") ///
					b1title("") l1title("") ///
					var2opts(label(ang(0) labsize(small))) ///
					ytitle("% of respondents", size(vsmall)) legend(cols(3))  ///
					note("{it: Male = `num_m', Female = `num_f' }" "{it:}" "{it: None = `num_10', Primary = `num_20', Middle = `num_30', Matric = `num_40', Inter = `num_70'}" "{it: Bachelors = `num_80', Masters = `num_90', PhD = `num_100', Other = `num_110' }", size(vsmall)) 
					
**years of experience by gender
recode exp_total_yrs (1111=.) (3217=.)
gen exp = .
replace exp = 0 if exp_total_yrs == 0
replace exp = 1 if exp_total_yrs > 0 & exp_total_yrs <= 2
replace exp = 2 if exp_total_yrs > 2 & exp_total_yrs <= 5
replace exp = 3 if exp_total_yrs > 5 & exp_total_yrs <= 10
replace exp = 4 if exp_total_yrs > 10 & exp_total_yrs <= 20
replace exp = 5 if exp_total_yrs > 21 & exp_total_yrs != .

//lab def exp 0 "0" 1 "1-2" 2 "3-5" 3 "6-10" 4 "11-20" 5 "21+"
lab val exp exp

count if gender_resp == 1 
local num_f =`r(N)'
count if gender_resp == 2 
local num_m =`r(N)'
count if exp == 0
local num_0 = `r(N)'
count if exp == 1 
local num_1 = `r(N)'
count if exp == 2
local num_2 = `r(N)'
count if exp == 3 
local num_3 = `r(N)'
count if exp == 4
local num_4 = `r(N)'
count if exp == 5 
local num_5 = `r(N)'

catplot gender_resp exp, percent(gender_resp) asyvars ///
					recast(bar) graphregion(color(white)) ///
					var1opts(label(ang(45) labsize(3))) ///
					title("Years of Experience") ///
					b1title("") l1title("") ///
					ytitle("% of respondents", size(small)) legend(cols(3))  ///
					note("{it: no. male subscribers = `num_m', no. female subscribers = `num_f' }" "{it: }" "{it: 0 yrs = `num_0', 1-2 yrs = `num_1', 3-5 yrs = `num_2', 6-10 yrs = `num_3', 11-20 yrs = `num_4', 21+ yrs = `num_5' }", size(vsmall)) 

**access to ind. transport by gender
count if gender_resp == 1 & travel1 != .
local num_f =`r(N)'
count if gender_resp == 2 & travel1 != .
local num_m =`r(N)'

lab def travelmode 0 "Can only work from home" 1 "Can drive myself to work" 2 "Someone WILL pick & drop me" 3 "Someone MIGHT pick and drop me" 4 "Do not have ind. transport", modify

catplot travel1 gender_resp, percent(gender_resp) stack asyvars ///
					recast(bar) graphregion(color(white)) ///
					var1opts(label(ang(45) labsize(small))) ///
					title("Independent Transport") ///
					subtitle("Job Talash Subscribers") ///
					b1title("") l1title("") ///
					ytitle("% of respondents", size(small)) legend(cols(2) size(small))  ///
					note("{it: Do you have independent transport if you find a job?} {it: no. male subscribers = `num_m', no. female subscribers = `num_f'}", size(vsmall)) 


**modes of job search at baseline -- JT

		count if job_steps ! = ""
		local nb_obs = `r(N)'

		graph bar  job_steps3  job_steps1  job_steps2 job_steps4 job_steps5 job_steps6, percent title("Baseline Job Search") ///
		///$shades5 ///
		graphregion(color(white))  blabel( total, position(outside) format(%5.3f) color(black)  size(small)) ///
		legend(label(1 "Sought assistance from friends, relatives etc") label(2 "Applied to prospective employer") ///
		label(3 "Checked at work sites, factories, markets, etc.") label(4 "Placed or answered advertisements")  ///
		label(5 "Registered with an employment agency") label(6 "Other")  size(vsmall)) ///
		note("{it: Question: Have you taken any of the following steps to find a job in the last month? N = `r(N)' individuals.}", size(vsmall)) ytitle("percentage")

** importance of employer pick and drop by gender
lab def pad 1 "Extremely Important" 2 "Very Important" 3 "Somewhat Important" 4 "Not Important"
lab travel3 pad

		count if gender_resp == 1 & travel3 != .
		local num_m =`r(N)'
		count if gender_resp == 2 & travel3 != .
		local num_f =`r(N)'

catplot travel3 gender_resp, percent(gender_resp) stack asyvars ///
					recast(bar) graphregion(color(white)) ///
					var1opts(label(ang(45) labsize(small))) ///
					title("Importance of Employer Pick and Drop", size(medium)) ///
					b1title("") l1title("") ///
					ytitle("% of respondents", size(small)) legend(size(small))  ///
					note("{it: How important is employer pick and drop in your decision to take a job?} {it: no. male subscribers = `num_m', no. female subscribers = `num_f'}", size(vsmall)) 

**willingness to take modes of transport at baseline -- JT

preserve
	keep if gender_resp == 2
		foreach mode in pubbus pubwagon rickshaw pickdrop {
		recode travel2_`mode' (2=0)
		}
		
		ren travel2_pubbus transport_1
		ren travel2_pubwagon transport_2
		ren travel2_rickshaw transport_3
		ren travel2_pickdrop transport_4

		foreach i of numlist 1/4 { 
		sum transport_`i'
		local nb_obs_`i' = `r(N)'
		gen transport_mean`i' = `r(mean)'*100
			}
		keep transport_mean*
		duplicates drop

		gen helper = 1
		reshape long transport_mean, i(helper) j(mode)
			
		label define transport 1 "Public Bus" 2 "Public Wagon" 3 "Rickshaw" ///
		4 "Employer Pick and Drop" 

		label values mode transport
			
		graph bar transport_mean, over(mode, label(labsize(small)) sort(1) descending) ///
		graphregion(color(white)) blabel(total, position(outside) format(%5.1f) color(black)  size(vsmall)) ///
		title("Modes of Transportation" " " "Male Subscribers", size(medium)) ytitle("% of respondents", size(medium)) ///
		subtitle("% willing to use mode", size(small)) ///
		note("{it: Qs: Which of the following modes of transport would you use to travel to work?}" ///
		"{it: N= `nb_obs_1' ; `nb_obs_2' ; `nb_obs_3'; `nb_obs_4'.}", size(vsmall)) 

restore

preserve
	keep if gender_resp == 1
		foreach mode in pubbus pubwagon rickshaw pickdrop {
		recode travel2_`mode' (2=0)
		}
		
		ren travel2_pubbus transport_1
		ren travel2_pubwagon transport_2
		ren travel2_rickshaw transport_3
		ren travel2_pickdrop transport_4

		foreach i of numlist 1/4 { 
		sum transport_`i'
		local nb_obs_`i' = `r(N)'
		gen transport_mean`i' = `r(mean)'*100
			}
		keep transport_mean*
		duplicates drop

		gen helper = 1
		reshape long transport_mean, i(helper) j(mode)
			
		label define transport 1 "Public Bus" 2 "Public Wagon" 3 "Rickshaw" ///
		4 "Employer Pick and Drop" 

		label values mode transport
			
		graph bar transport_mean, over(mode, label(labsize(small)) sort(1) descending) ///
		graphregion(color(white)) blabel(total, position(outside) format(%5.1f) color(black)  size(vsmall)) ///
		title("Modes of Transportation" " " "Female Subscribers", size(medium)) ytitle("% of respondents", size(medium)) ///
		subtitle("% willing to use mode", size(small)) ///
		note("{it: Qs: Which of the following modes of transport would you use to travel to work?}" ///
		"{it: N= `nb_obs_1' ; `nb_obs_2' ; `nb_obs_3'; `nb_obs_4'.}", size(vsmall)) 

restore

